package com.wanmait.computershop.webController;

import com.wanmait.computershop.dao.ProductDAO;
import com.wanmait.computershop.dao.WebIndexDao;
import com.wanmait.computershop.vo.CateGory;
import com.wanmait.computershop.vo.Product;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("web")
public class WebIndexController {

    @GetMapping("index")
    public String index(Model model, HttpSession session){
        //获取导航栏商品分类
        WebIndexDao webIndexDao = new WebIndexDao();
        List<CateGory> cateGoryList = webIndexDao.findProductsType();
        session.setAttribute("cateGoryList",cateGoryList);

        //获取新到好货
        List<Product> newProductList = webIndexDao.findNewProduct();
        model.addAttribute("newProductList",newProductList);

        //获取热销排行
        List<Product> hotProductList = webIndexDao.findHotProduct();
        model.addAttribute("hotProductList",hotProductList);
        return "index";
    }


}
